package self.hoy.demo.grainmall.search.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import self.hoy.demo.grainmall.search.service.MallSearchService;
import self.hoy.demo.grainmall.search.vo.SearchParam;
import self.hoy.demo.grainmall.search.vo.SearchResult;

/**
 * @author hyh
 * @date 2020/7/22
 */
@Controller
public class SearchController {

    @Autowired
    private MallSearchService mallSearchService;

    /**
     * http://search.grain.cn/search.html?catalog3Id=264
     * @return
     */
    @GetMapping("/search.html")
    public String search(SearchParam searchParam, Model model) {
        SearchResult result = mallSearchService.search(searchParam);
        model.addAttribute("result", result);
        return "search";
    }
}
